<?php 

class PasswordGenerator
{
	public static function GeneratePassword( $Syllables = 3 )
	{
		$vowels = array ('a', 'o', 'e', 'i', 'y', 'u', 'ou', 'oo');
		$consonants = array ('w', 'r', 't', 'p', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'z', 'x', 'c', 'v',	'b', 'n', 'm', 'qu');
		for ($i=0, $password=''; $i<$Syllables; $i++) $password .= self::MakeSyllable($vowels, $consonants, $i);
		return $password.self::MakeSuffix($vowels, $consonants);
	}
	
	private static function MakeSuffix ($vowels, $consonants)
	{
		$suffix = array ('dom', 'ity', 'ment', 'sion', 'ness', 'ence', 'er', 'ist', 'tion', 'or');
		$new = $suffix[array_rand($suffix)];
		return (in_array($new[0], $vowels)) ? $consonants[array_rand($consonants)].$new : $new;
	}
	
	private static function MakeSyllable ($vowels, $consonants, $double=false)
	{
		$doubles = array('n', 'm', 't', 's');
		$c = $consonants[array_rand($consonants)];
		if ($double AND in_array($c, $doubles) AND 1 == mt_rand(0,2)) $c .= $c;
		return $c.$vowels[array_rand($vowels)];
	} 
}

?>